﻿using System;

namespace Net.Formats.oEmbed
{
    /// <summary>
    /// This type is used for representing playable videos. 
    /// Responses of this type must obey the maxwidth and maxheight  
    /// request parameters. If a provider wishes the consumer to just provide a 
    /// thumbnail, rather than an embeddable player, they should instead return 
    /// a <see cref="Net.Formats.oEmbed.PhotoResponse"> photo response type</see>.
    /// </summary>
    public class VideoResponse : GenericResponse
    {
        #region Class Constructor

        public VideoResponse( ) : base( ResponseType.Video ) { }

        #endregion

        #region Private Fields

        string html;
        int? width;
        int? height;

        #endregion

        #region Public Properties

        /// <summary>
        /// The HTML required to embed a video player. The HTML should have no padding or 
        /// margins. Consumers may wish to load the HTML in an off-domain iframe to 
        /// avoid XSS vulnerabilities.
        /// </summary>
        public string Html
        {
            get
            {
                if ( string.IsNullOrEmpty(html) )
                    throw new ArgumentNullException( "Html is a required property" );
                return html;
            }
            set
            {
                if ( html != value )
                    html = value;
            }
        }

        /// <summary>
        /// The width in pixels required to display the HTML.
        /// </summary>
        public int? Width
        {
            get
            {
                if ( !width.HasValue )
                    throw new ArgumentNullException( "Width is a required property" );
                return width;
            }
            set
            {
                if ( width != value )
                    width = value; 
            }
        }

        /// <summary>
        /// The height in pixels required to display the HTML.
        /// </summary>
        public int? Height
        {
            get
            {
                if ( !height.HasValue )
                    throw new ArgumentNullException( "Height is a required property" );
                return height;
            }
            set
            {
                if ( height != value )
                    height = value;
            }
        }

        #endregion
    }
}
